<script setup>
import { defineEmits } from 'vue';
const emits = defineEmits(['selectPages','logout'])
const selectPages = (pageidx) => {
    emits("selectPages", pageidx)
}
const username = 'testuser'

const logout=()=>
{
    console.log('logout')
    emits("logout")
}
</script>



<template>
    <v-navigation-drawer expand-on-hover rail>
        <v-list>
            <v-list-item prepend-icon="mdi-account">
                <v-list-item-content>
                    <v-list-item-title>{{ this.$root.userinfo.name }}</v-list-item-title>
                    <v-list-item-subtitle>{{ this.$root.userinfo.department }}</v-list-item-subtitle>
                </v-list-item-content>
            </v-list-item>
        </v-list>

        <v-divider></v-divider>

        <v-list v-if="this.$root.userinfo.role == 'student'" density="compact" nav>
            <v-list-item @click="selectPages(0)" prepend-icon="mdi-plus" title="选择课程"></v-list-item>
            <v-list-item @click="selectPages(1)" prepend-icon="mdi-delete" title="删除课程"></v-list-item>
            <v-list-item @click="selectPages(2)" prepend-icon="mdi-check" title="查询已选课程"></v-list-item>
            <v-list-item @click="selectPages(3)" prepend-icon="mdi-book-search" title="查询成绩"></v-list-item>
        </v-list>
        <v-list v-if="this.$root.userinfo.role == 'teacher'" density="compact" nav>
            <v-list-item @click="selectPages(10)" prepend-icon="mdi-account-group" title="学生管理"></v-list-item>
            <v-list-item @click="selectPages(11)" prepend-icon="mdi-school" title="成绩登记"></v-list-item>
            <v-list-item @click="selectPages(12)" prepend-icon="mdi-clipboard-check" title="签到发布"></v-list-item>
            </v-list>
        <v-list v-if="this.$root.userinfo.role == 'admin'" density="compact" nav>
            <v-list-item @click="selectPages(20)" prepend-icon="mdi-folder" title="管理员界面" value="admin"></v-list-item>
        </v-list>
        <template v-if="this.$root.islogin" v-slot:append>
          <div class="pa-2">
            <v-btn block rounded="2" @click="logout" >
                <v-icon mid>mdi-logout</v-icon>
            </v-btn>
          </div>
        </template>
    </v-navigation-drawer>
</template>